package com.example.administrator.capital.presenter;

import com.example.administrator.capital.model.ConsultModel;
import com.example.administrator.capital.model.base.IActionRequest;
import com.example.administrator.capital.presenter.base.BasePresenter;
import com.example.administrator.capital.presenter.base.IViewBase;
import com.example.administrator.capital.presenter.base.IViewRequest;
import com.lzy.okgo.model.Response;

/**
 * Created by Administrator on 2017/12/19 0019.
 *
 */
public class ConsultPresenter extends BasePresenter {
    private ConsultModel mConsultModel;
    public ConsultPresenter(IViewBase iViewBase) {
        super(iViewBase);
        mConsultModel = new ConsultModel();
    }

    /**
     * @param iViewRequest
     * @param uid
     * 查看资讯接口
     */
    public void selectarticle(final IViewRequest<String> iViewRequest, String uid){
        mConsultModel.selectarticle(new IActionRequest<String>() {
            @Override
            public void failMsg(String var) {
                iViewRequest.onFailMsg(var);
            }

            @Override
            public void code(int code) {
                iViewRequest.onCode(code);
            }

            @Override
            public void success(Response<String> data) {
                iViewRequest.onSuccess(data);
            }

            @Override
            public void fail(Response<String> error) {

            }
        },uid);
    }

    /**
     * @param iViewRequest
     * 资讯列表接口
     */
    public void articlelist(final IViewRequest<String> iViewRequest){
        mConsultModel.articlelist(new IActionRequest<String>() {
            @Override
            public void failMsg(String var) {
                iViewRequest.onFailMsg(var);
            }

            @Override
            public void code(int code) {
                iViewRequest.onCode(code);
            }

            @Override
            public void success(Response<String> data) {
                iViewRequest.onSuccess(data);
            }

            @Override
            public void fail(Response<String> error) {

            }
        });
    }

    /**
     * @param iViewRequest
     * @param id
     * 资讯详情html页面
     */
    public void article(final IViewRequest<String> iViewRequest, String id){
        mConsultModel.article(new IActionRequest<String>() {
            @Override
            public void failMsg(String var) {
                iViewRequest.onFailMsg(var);
            }

            @Override
            public void code(int code) {
                iViewRequest.onCode(code);
            }

            @Override
            public void success(Response<String> data) {
                iViewRequest.onSuccess(data);
            }

            @Override
            public void fail(Response<String> error) {

            }
        },id);
    }
}
